﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using weikebuluo.DAL;
using weikebuluo.Common;
using weikebuluo.Model;

namespace weikebuluo.web.wechat.market
{
    public partial class publish : System.Web.UI.Page
    {
        a_product_dal productdal = new a_product_dal();
        a_product_model productmodel = new a_product_model();

        protected void Page_Load(object sender, EventArgs e)
        {
            switch (Request.Form["action"]) {
                case "add":
                    add();
                    break;
            }
        }

        private void add() {

            productmodel.product_name = Request.Form["title"].Trim().ToString();
            if (!string.IsNullOrEmpty(Request.Form["pimg"]))
            {
                productmodel.product_picurl = Request.Form["pimg"].Trim().ToString();
            }
            else {
                productmodel.product_picurl = "http://www.weikebuluo.com/Picture/News/16/image/20140514/20140514080149_0912.jpg";
            }
            productmodel.product_price = decimal.Parse(Request.Form["price"].Trim().ToString());
            productmodel.product_byname = Request.Form["name"].Trim().ToString();
            productmodel.product_phone = Request.Form["phone"].Trim().ToString();
            productmodel.product_text = Request.Form["content"].Trim().ToString();
            productmodel.user_id = int.Parse(Request.Form["uid"].Trim().ToString());
            productmodel.wxid = Request.Form["wxid"].Trim().ToString();
            productdal.Add(productmodel);
            Response.Write("<script Language=\"Javascript\">top.location=\"product_list.aspx?uid=" + Request.Form["uid"].Trim().ToString() + "&wxid=" + Request.Form["wxid"].Trim().ToString() + "\";");
            Response.Write("</script>");
            Response.End();
        }
    }
}